// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage

//testcase name：参数修改
//author：feizhao
//date：2017-11-21
//discription：用于测试登陆后，综合业务-参数管理的页面新增参数
//step：1.登录主页面  2.录入新增参数信息  3.查询需修改参数  4.修改信息  5.环境恢复
//修改人：
//修改日期：
//修改内容：

//Account setting.
 const accountConfig = {
  username: '1',
  password: '1',
}
 module.exports = {
   'login tests': function (browser) {
     browser
     .url('http://127.0.0.1:8080').maximizeWindow()
     .pause(1000)
     .waitForElementVisible('body', 100)
     .setValue('input[type=text]',accountConfig.username)
     .pause(100)
     .setValue('input[type=password]',accountConfig.password)
     .pause(100)
     .click('button[id=login-button]')
     .pause(1000)
//点击综合业务-参数管理-修改参数
      //新增参数
     .click('#vc-tree-name-综合业务')
     .pause(1000)
     .click('#vc-tree-name-参数管理')
     .pause(3000)
     .click('#unit :first-child div :first-child span')
     .pause(1000)
     .setValue('#unit :first-child div :nth-child(4) div div :nth-child(2) div input[type=text]','测试新增参数')
     .pause(1000)
     .click('#unit :first-child div :nth-child(4) div div :nth-child(3) :last-child')
     .pause(1000)
     .click('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)')
     .pause(1000)
     .click('#unit div div :nth-child(4) span')
     .pause(1000)
     .setValue('#unit div div :nth-child(6) div div :nth-child(2) input[type=text]','新增测试')
     .pause(1000)
     .click('#unit div div :nth-child(6) div div :nth-child(3) :last-child ')
     .pause(1000)
     //查询参数
     .setValue('#unit :first-child div :nth-child(2) input[placeholder=请输入查找的参数名]','测试新增参数')
     .pause(1000)
     .click('#unit :first-child div :nth-child(2) button')
     .pause(1000)
     //修改参数
     .click('#unit div div :nth-child(3) div div table :nth-child(2) tr :last-child button:first-child')
     .pause(1000)
     .clearValue('#unit :first-child div :nth-child(4) div div :nth-child(2) div input[type=text]')
     .pause(1000)
     .setValue('#unit :first-child div :nth-child(4) div div :nth-child(2) div input[type=text]','测试修改参数')
     .pause(1000)
     .click('#unit :first-child div :nth-child(4) div div :nth-child(3) :last-child')
     .pause(1000)
     browser.expect.element('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)').text.to.equal('测试修改参数')
     browser.pause(1000)
     .pause(1000)
     //查询参数-修改参数下拉列表
     .clearValue('#unit :first-child div :nth-child(2) input[placeholder=请输入查找的参数名]')
     .pause(500)
     .setValue('#unit :first-child div :nth-child(2) input[placeholder=请输入查找的参数名]','测试修改参数')
     .pause(1000)
     .click('#unit :first-child div :nth-child(2) button')
     .pause(1000)
     .click('#unit div div :nth-child(3) div div table :nth-child(2) tr td:nth-child(2)')
     .pause(1000)
     .click('#unit div div :nth-child(5) div div table :nth-child(2) tr :last-child button:first-child')
     .pause(500)
     .clearValue('#unit div div :nth-child(6) div div :nth-child(2) input[type=text]')
     .pause(500)
     .setValue('#unit div div :nth-child(6) div div :nth-child(2) input[type=text]','测试')
     .pause(1000)
     .click('#unit div div :nth-child(6) div div :nth-child(3) button:last-child')
     .pause(1000)
     browser.expect.element('#unit div div :nth-child(5) div div table :nth-child(2) tr td:nth-child(2)').text.to.equal('测试')
//环境恢复
     browser.pause(1000)
     .click('#unit div div :nth-child(5) div div table :nth-child(2) tr td:nth-child(3) button:last-child')
     .pause(1000)
     .click('#vc-messagebox-confirm')
     .pause(1000)
     .click('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(3) button:last-child')
     .pause(1000)
     .click('#vc-messagebox-confirm')
     .pause(1000)
     browser.expect.element('#unit :first-child div :nth-child(3) div div table :nth-child(2) :last-child td:nth-child(2)').text.not.to.equal('测试修改参数')
     browser.pause(3000)
     .end()
   }
 }
